<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"
	dir="ltr">
<head>
<title>Moment Mobile Payments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="../styles/layout.css" type="text/css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<style>
.control-label {
	display: inline-block;
	width: 250px;
}

.control-group {
	padding-bottom: 10px;
}
</style>

</head>
<body id="top">
	<%@include file="loggedinheader.jsp"%>
	<%@ page import="org.json.*"%>
	<%@ page import="com.moment.model.*"%>
	<%@page import="com.moment.webservice.*"%>
	<%@page import="com.moment.util.Converter"%>
	<%@page import="java.util.HashMap"%>
	<%@page import="java.util.Map"%>
	<%@ page language="java" contentType="text/html; charset=UTF-8"
		pageEncoding="UTF-8"%>
	<%@page import="java.util.*"%>
	<%!String s[];%>
	<%
		System.out.println("Session name"
				+ session.getAttribute("username"));
		if ((session.getAttribute("username") == null)
				|| (session.getAttribute("username") == "")) {
	%>
	You are not logged in
	<br />
	<a href="index.jsp">Please Login</a>
	<%
		} else {
	%>


	<jsp:useBean id="userObj" class="com.moment.model.UserReg"
		scope="session" />
	<div class="wrapper col3">

		<div id="intro">
			<div id="logout">
				<a href="/MMP/LogoutController"><img src="images/logout.png"
					alt="Logout" /></a>
			</div>
			<div class="fl_left1">

				<div id="login1">
					<div class="imgl">
						<img alt="Embedded Image" height="128" width="128"
							src="data:image/jpeg;base64,<jsp:getProperty name="userObj" property="imagestr" />" />
					</div>
				</div>
				<div id="instrumentsmain">
					<div>

						<h2>
							Welcome
							<jsp:getProperty name="userObj" property="name1" />

						</h2>


					</div>
					<%
						String inst = request.getParameter("inst");
							String mode = request.getParameter("mode");
							String pmode = (mode.equals("p")) ? "Paid" : "Received";
							//--New CODE-------------
							Map<String, String> map = new HashMap<String, String>();
							map.put("method", "1");
							map.put("mnum", (String) session.getAttribute("username"));
							map.put("action",mode);
							map.put("instrumentname",inst);
							String json = new Converter().mapToJson(map);
							System.out.println("json String :" + json);
							Services serviceproxy = new ServicesProxy();

							String tdetails = serviceproxy.service(json);
							// ---------------------------
							
							
							if (!tdetails.equals("Fail")) {
					%>
					<center>
						<p><%=pmode%>
							Payment History
							<%=inst%></p>
					</center>
					<div class="slide-toggle1">

						<table border=2 style="margin-left: 0px;">
							<tr>
								<td>Serial No.</td>
								<td>Payee</td>
								<td>Amount</td>
								<td>Date</td>
							</tr>
							<%
								String[] tdetails_array = tdetails.split("[$]");
										int count = 0;
										for (String s : tdetails_array) {

											//out.print(s + "<br/>");
											String[] curr_tdetail = s.split("[?]");

											out.print("<tr>");
											out.print("<td>" + ++count + "</td>");
											out.print("<td>" + curr_tdetail[0] + "</td>");
											out.print("<td>" + curr_tdetail[1] + "</td>");
											out.print("<td>" + curr_tdetail[2] + "</td>");
											out.print("</tr>");
										}
										//out.print("</table>");
										//	out.print("Show All");
									} else {
										out.print("No transaction history found");
									}
							%>
						</table>
					</div>

				</div>

			</div>
		</div>
	</div>
	<br class="clear" />

	<%
		}
	%>
	<%@include file="footer.jsp"%>
</body>
</html>

